home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / build / win32 / lt-compile-resource < prev    next >
Encoding:
Text File  |  2002-09-19  |  1.7 KB  |  66 lines

  1. #!/bin/bash
  2.  
  3. # Script to compile a resource file for a DLL in the same way that
  4. # libtool would, if it knew about .rc files.
  5.  
  6. # This kinda sucks, but the alternative would be to teach autoconf,
  7. # automake, and libtool about compiling .rc files.  That would be
  8. # doable, but waiting for those changes to propagate to official
  9. # versions of those tools would take some time.
  10.  
  11. # The command line arguments are:
  12. # $1: the name of the .rc file to compile if it exists
  13. # $2: the name of the resource libtool object file to produce
  14.  
  15. rcfile=$1
  16. lo=$2
  17. case "$lo" in
  18. *.lo) 
  19.     resfile=.libs/`basename $lo .lo`.o
  20.     ;;
  21. *)
  22.     echo libtool object name should end with .lo
  23.     exit 1
  24.     ;;
  25. esac
  26. d=`dirname $0`
  27.  
  28. # Create .libs if not there already
  29. [ ! -d .libs ] && mkdir .libs
  30.  
  31. # Super-ugly hack: libtool can work in two ways on Win32: Either it
  32. # uses .lo files which are the real object files in "this" directory,
  33. # or it creates .o files in the .libs subdirectory, and the .lo file
  34. # is a small text file. We try to deduce which case this is by
  35. # checking if there are any .o files in .libs. This requires that the
  36. # resource file gets built last in the Makefile.
  37.  
  38. o_files_in_dotlibs=`echo .libs/*.o`
  39. case "$o_files_in_dotlibs" in
  40.     .libs/\*.o)
  41.     use_script=false
  42.     ;;
  43.     *)  use_script=true
  44.     ;;
  45. esac
  46.  
  47. # Try to compile resource file
  48. $d/compile-resource $rcfile $resfile && {
  49.     if [ $use_script = true ]; then
  50.     # Handcraft a libtool object
  51.     # libtool checks for a second line matching "Generated by .* libtool"!
  52.     (echo "# $lo"
  53.     echo "# Generated by lt-compile-resource, compatible with libtool"
  54.     echo "pic_object=$resfile"
  55.     echo "non_pic_object=none") >$lo
  56.     else
  57.     mv $resfile $lo
  58.     fi
  59.     # Success
  60.     exit 0
  61. }
  62.  
  63. # If unsuccessful (no .rc file, or some error in it) return failure
  64.  
  65. exit 1
  66.